﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class UIEnemyNum : MonoBehaviour
{
    public Text text;
    private int count;
    private string str = "敌人数量:";

    private void Awake()
    {
        text = this.GetComponent<Text>();
    }

    private void Start()
    {
        count = LevelManager.Instance.enemyArray.Length;

        text.text = str + count;
    }

    private void OnEnable()
    {
        EventMgr.Register(Events.ON_ENEMY_KILLED, OnEnemyKilled);
    }

    private void OnDisable()
    {
        EventMgr.UnRegister(Events.ON_ENEMY_KILLED, OnEnemyKilled);
    }

    void OnEnemyKilled(object arg1, System.EventArgs arg2)
    {
        count--;
        text.text = str + count;
    }

}
